/**
 * 
 */
package com.easidea.tim.entity.system.orgnization;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;
import com.easidea.tim.entity.system.permission.Role;

/**
 * @author Harrison
 *
 */
@Entity(name="tim_orgnization_staff")
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Cache(region="tim_orgnization_staff",usage=CacheConcurrencyStrategy.READ_WRITE)
@Undeletable(status="deleted")
public class Staff extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7399586100130814139L;

	public static final Short STAFF_STATUS_NON_ACTIVE = 0; //未激活，未创建登录帐号
	public static final Short STAFF_STATUS_ACTIVED = 1; //已激活，已创建登录帐号
	public static final Short STAFF_STATUS_DISABLED = -1; //已激活，已关闭
	
	public static final Short STAFF_GENDER_MALE = 1; // 男生
	public static final Short STAFF_GENDER_FEMALE = 0; // 女生
	
	public static final Short STAFF_URGENCY_CONTACTOR_RELATION_FAMILY = 1; // 紧急联系人关系：家人
	public static final Short STAFF_URGENCY_CONTACTOR_RELATION_BOSOM_FRIEND = 0; // 紧急联系人关系：密友
	public static final Short STAFF_URGENCY_CONTACTOR_RELATION_FRIEND = 2; // 紧急联系人关系：普通朋友
	
	
	private String name;
	private Date birth; 
	private Short gender; //  性别
	private String position; // 职务
	private String mobile; // 手机号 
	private String email; // email
	private String homeTel; // 家庭电话
	private String address; // 地址
	private String urgencyCall; //紧急联系方法
	private String urgencyContactor; //紧急联系人
	private Short contactorRelation; //紧急联系人关系
	private Date dutyDate; // 入职时间
	private Date lastLogonTime; //最后登录时间
	private Short status; //状态
	private String username;
	private String password;
	private String memo;
	private Department department; // 所属部门
	private List<Role> roleList; // 拥有角色

	private Short recursionSearch = 0; 

	private StaffCreditLimit creditLimit;//员工授信额度
	
	public Staff() {
		
	}
	public Staff(Long id, String name, String username) {
		this.id = id;
		this.name = name;
		this.username = username;
	}

	/**
	 * @return the name
	 */
	@Column(name="name",nullable=false)
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the birth
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="birth")
	public Date getBirth() {
		return birth;
	}
	/**
	 * @param birth the birth to set
	 */
	public void setBirth(Date birth) {
		this.birth = birth;
	}
	/**
	 * @return the gender
	 */
	@Column(name="gender",nullable=false)
	public Short getGender() {
		return gender;
	}
	/**
	 * @param gender the gender to set
	 */
	public void setGender(Short gender) {
		this.gender = gender;
	}
	/**
	 * @return the position
	 */
	@Column(name="position")
	public String getPosition() {
		return position;
	}
	/**
	 * @param position the position to set
	 */
	public void setPosition(String position) {
		this.position = position;
	}
	/**
	 * @return the mobile
	 */
	@Column(name="mobile")
	public String getMobile() {
		return mobile;
	}
	/**
	 * @param mobile the mobile to set
	 */
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	/**
	 * @return the email
	 */
	@Column(name="email")
	public String getEmail() {
		return email;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the homeTel
	 */
	@Column(name="home_tel")
	public String getHomeTel() {
		return homeTel;
	}
	/**
	 * @param homeTel the homeTel to set
	 */
	public void setHomeTel(String homeTel) {
		this.homeTel = homeTel;
	}
	/**
	 * @return the address
	 */
	@Column(name="address")
	public String getAddress() {
		return address;
	}
	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}
	/**
	 * @return the urgencyCall
	 */
	@Column(name="urgency_call")
	public String getUrgencyCall() {
		return urgencyCall;
	}
	/**
	 * @param urgencyCall the urgencyCall to set
	 */
	public void setUrgencyCall(String urgencyCall) {
		this.urgencyCall = urgencyCall;
	}
	/**
	 * @return the urgencyContactor
	 */
	@Column(name="urgency_contactor")
	public String getUrgencyContactor() {
		return urgencyContactor;
	}
	/**
	 * @param urgencyContactor the urgencyContactor to set
	 */
	public void setUrgencyContactor(String urgencyContactor) {
		this.urgencyContactor = urgencyContactor;
	}
	/**
	 * @return the contactorRelation
	 */
	@Column(name="contactor_relation")
	public Short getContactorRelation() {
		return contactorRelation;
	}
	/**
	 * @param contactorRelation the contactorRelation to set
	 */
	public void setContactorRelation(Short contactorRelation) {
		this.contactorRelation = contactorRelation;
	}
	/**
	 * @return the dutyDate
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="duty_date", nullable=false)
	public Date getDutyDate() {
		return dutyDate;
	}
	/**
	 * @param dutyDate the dutyDate to set
	 */
	public void setDutyDate(Date dutyDate) {
		this.dutyDate = dutyDate;
	}
	/**
	 * @return the lastLogonTime
	 */
	@Column(name="last_logon_time")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getLastLogonTime() {
		return lastLogonTime;
	}
	/**
	 * @param lastLogonTime the lastLogonTime to set
	 */
	public void setLastLogonTime(Date lastLogonTime) {
		this.lastLogonTime = lastLogonTime;
	}
	/**
	 * @return the status
	 */
	@Column(name="status")
	public Short getStatus() {
		return status;
	}
	/**
	 * @param status the status to set
	 */
	public void setStatus(Short status) {
		this.status = status;
	}
	/**
	 * @return the username
	 */
	@Column(name="username")
	public String getUsername() {
		return username;
	}
	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}
	/**
	 * @return the password
	 */
	@Column(name="password")
	public String getPassword() {
		return password;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return the memo
	 */
	@Column(name="memo")
	public String getMemo() {
		return memo;
	}
	/**
	 * @param memo the memo to set
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}
	/**
	 * @return the department
	 */
	@ManyToOne(cascade=CascadeType.MERGE)
	@JoinColumn(name="dept_id", nullable=false)
	public Department getDepartment() {
		return department;
	}
	/**
	 * @param department the department to set
	 */
	public void setDepartment(Department department) {
		this.department = department;
	}
	@OneToOne(mappedBy="staff")
	public StaffCreditLimit getCreditLimit() {
		return creditLimit;
	}
	public void setCreditLimit(StaffCreditLimit creditLimit) {
		this.creditLimit = creditLimit;
	}
	/**
	 * @return the roleList
	 */
	@ManyToMany(cascade=CascadeType.PERSIST,fetch=FetchType.LAZY)
	@JoinTable(name="tim_permission_staff_role_rel",
			joinColumns={@JoinColumn(name="staff_id",referencedColumnName="id",table="tim_orgnization_staff")},
			inverseJoinColumns={@JoinColumn(name="role_id",referencedColumnName="id",table="tim_permission_role")})
	public List<Role> getRoleList() {
		return roleList;
	}
	/**
	 * @param roleList the roleList to set
	 */
	public void setRoleList(List<Role> roleList) {
		this.roleList = roleList;
	}
	@Column(name="recursion_search")
	public Short getRecursionSearch() {
		return recursionSearch;
	}
	public void setRecursionSearch(Short recursionSearch) {
		this.recursionSearch = recursionSearch;
	}
	
	
	
	
}
